package cn.dlc.com;

import org.junit.Test;

import java.net.InetAddress;
import java.util.Properties;

/**
 * @author deng
 * @date 2021/6/28 16:16
 **/
public class Demo {

    public static void main(String[] args) throws Exception{
        testOs();
        long sizeOfPhysicalMemory = Hardware.getSizeOfPhysicalMemory();
        System.out.println(sizeOfPhysicalMemory / 1024 / 1024 / 1024 + "GB");
    }

    public static void testOs() throws Exception{

        InetAddress addr = InetAddress.getLocalHost();
        String ip = addr.getHostAddress().toString(); //获取本机ip
        String hostName = addr.getHostName().toString(); //获取本机计算机名称

        System.out.println(ip + ": " + hostName);

        Properties props = System.getProperties();
        System.out.println("操作系统的名称：" + props.getProperty("os.name"));
        System.out.println("操作系统的版本号：" + props.getProperty("os.version"));

        System.out.println("cpu内核数量：" +Runtime.getRuntime().availableProcessors());




    }
}
